package com.my.chapter8;

public class practice9 {
    public static void main(String[] args) {
        Rodent[] r = {
                new Rodent(),
                new Mouse(),
                new Gerbil(),
                new Hamster()
        };
        for(int i=0;i<r.length;i++){
            r[i].eat();
        }
    }
}

class Rodent{
    public void eat(){
        System.out.println("啮齿动物吃东西");
    }
}

class Mouse extends Rodent{
    public void eat(){
        System.out.println("老鼠吃东西");
    }
}

class Gerbil extends Rodent{
    public void eat(){
        System.out.println("鼹鼠吃东西");
    }
}

class Hamster extends Rodent{
    public void eat(){
        System.out.println("大颊鼠吃东西");
    }
}
